package ninja.awesome.game.gameobject;

import ninja.awesome.game.MainGameScreen;

public class XPSystem {


	MainGameScreen game;
	double experience_point = 0;
	double MaxExpPerLevel;
	public XPSystem(MainGameScreen game){
		this.game = game;


	}
	public void giveXP(int amount) {
		// add Xp to ninja

		game.getNinja().setExperiencePoint(game.getNinja().getExperiencePoint()+amount);

		if (game.getNinja().getLevel() >= 100) {
			// When Max level is 100 then it will not doing anything
		}

		if (experience_point >= MaxExpPerLevel) {
			game.getNinja().setExperiencePoint(game.getNinja().getNextLevel()+1);
			game.getNinja().setExperiencePoint(game.getNinja().getExperiencePoint() + MaxExpPerLevel*2);


		}


		else {
			// checks to see if the ninja has enough xp to level up
			if (game.getNinja().getExperiencePoint() > getXPForLevel(game.getNinja().getNextLevel())) {

				game.getNinja().setLevel(game.getNinja().getLevel()+1);

				game.getNinja().setNextLevel(game.getNinja().getNextLevel()+1);





				//System.out.println("Your level Up");
				//System.out.println("Ninja Level is now:" + MyNinja.level);
				//System.out.println("");
			}


		}
	}






	public int getXPForLevel(int nextLevel) {



		// gets the xp that is needed for the next level.
		return nextLevel;

	}
}

